function setDb(num) {
  //补零操作
  if (num < 10) {
    return "0" + num;
  } else {
    return "" + num;
  }
}
function setTimes(timer) {
  var time = new Date(timer);
  var year = time.getFullYear(); //年
  var mon = setDb(time.getMonth() + 1); //0
  var day = setDb(time.getDate()); //24
  var hour = setDb(time.getHours()); //时
  var min = setDb(time.getMinutes()); //分
  var sec = setDb(time.getSeconds()); //秒

  return {
    secs: sec,
    mins: min,
    hours: hour,
    days: day,
    mons: mon,
    years: year,
  };
}
function dateTime(num) {
  let data_time = setTimes(num);
  let years = data_time.years;
  let mons = data_time.mons;
  let days = data_time.days;
  let hour = data_time.mons;
  let min = data_time.mons;
  let secs = data_time.secs;
  return {
    format:
      years + "-" + mons + "-" + days + " " + hour + ":" + min + ":" + secs,
  };
}

module.exports = {
  dateTime,
};
